package com.qianfeng.smartmeeting;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import org.junit.Test;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class JWTtest {

    @Test
    public void testToken(){
        Map<String, Object> claims = new HashMap<>();
        claims.put("id", 1);
        claims.put("username", "zhangsan");

        String token = JWT.create()
                .withClaim("user", claims)
                .withExpiresAt(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 3))//添加过期时间
                .sign(Algorithm.HMAC256("smgljd"));//指定算法配置密钥

        System.out.println(token);
    }

}
